package me.ivps.android.servicedemo;

import me.ivps.android.servicedemo.ui.AnotherActivity;
import me.ivps.android.servicedemo.ui.MainActivity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainListActivity extends ListActivity {
    
    String[] name = { "MainActivity", "AnotherActivity" };
    Class<?>[] clazz = { MainActivity.class, AnotherActivity.class };
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, name);
        setListAdapter(adapter);
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        position %= clazz.length;
        startActivity(new Intent(this, clazz[position]));
    }
    
}